﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Windows.UI.Xaml;
using Huyn.MultiBinding;

namespace UniversalApp_Sample.MultiConverters
{
    public class BoolToVisibilityMultiConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, string language)
        {
            if (values == null || !values.Any())
                return false;
            if ((string)parameter=="inverse")
                return values.Where(v => v is bool).Any(c => (bool)c)?Visibility.Visible:Visibility.Collapsed;
            return values.Where(v => v is bool).All(c => (bool)c) ? Visibility.Visible : Visibility.Collapsed;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
